package com.yjz.study.adapter.account

import android.os.Bundle
import android.widget.TextView
import com.yjz.common.util.DateUtil
import com.yjz.common.util.HiRes
import com.yjz.study.R
import com.yjz.study.arouter.ARouterLogic
import com.yjz.study.http.entity.res.Notice
import com.yjz.ui.recycler.item.HiDataItem
import com.yjz.ui.recycler.item.HiViewHolder
import com.yjz.ui.view.IconFontTextView

/**
 *作用 :
 *作者 : yjz
 *时间 : 2025/5/23 15:37
 */
class CourseNoticeItem(itemData: Notice) : HiDataItem<Notice, HiViewHolder>(itemData) {
    override fun onBindData(holder: HiViewHolder, position: Int) {
        mData?.apply {

            val tv_title = holder.findViewById<TextView>(R.id.tv_title)
            val icon = holder.findViewById<IconFontTextView>(R.id.icon)

            tv_title?.text = title
            if ("goods" == type) {
                icon?.text = HiRes.getString(R.string.if_notice_recommend)
                holder.itemView.setOnClickListener {
                    val bundle = Bundle()
                    bundle.putString("goodsId", url)
                    ARouterLogic.navigation(ARouterLogic.Path.GOOD_DETAIL, bundle)
                }
            } else {
                icon?.text = HiRes.getString(R.string.if_notice_msg)
                holder.itemView.setOnClickListener {
                    ARouterLogic.startActivity4Browser(url)
                }
            }

            val tv_sub_title = holder.findViewById<TextView>(R.id.tv_sub_title)
            val tv_publish_date = holder.findViewById<TextView>(R.id.tv_publish_date)

            tv_sub_title?.text = subtitle
            tv_publish_date?.text = DateUtil.getMDDate(createTime)
        }
    }

    override fun getItemLayoutRes(): Int {
        return R.layout.layout_course_notice_item
    }
}